<!--# 
layout("/layout/madmin.html",{'breadCrumbs': [{'name':'主页','icon':'home','url':'/'},{'name':'团队创建','active':'active'}] ,'active':'team'}){ 
 #-->
<div class="panel panel-green">
	<div class="panel-heading">创建团队</div>
	<div class="panel-body pan">
		<form action="#" class="form-horizontal">
			<div class="form-body pal">
				<div class="form-group">
					<label for="inputUsername" class="col-md-3 control-label">团队名 <span class="require">*</span>
					</label>
					<div class="col-md-9">
						<div class="input-icon">
							<i class="fa fa-users"></i> <input id="name" name="name" type="text" placeholder="团队名称" class="form-control" data-type='required'>
						</div>
					</div>
				</div>
				<div class="form-group mbn">
					<label for="inputContent" class="col-md-3 control-label">团队简介</label>
					<div class="col-md-9">
						<textarea id="description" name="description" rows="3" class="form-control" placeholder="团队介绍"></textarea>
					</div>
				</div>
			</div>
			<div class="form-actions">
				<div class="col-md-offset-3 col-md-9">
					<button type="button" class="btn btn-primary">创建</button>
					&nbsp;
					<button type="button" class="btn btn-green btn-back">取消</button>
				</div>
			</div>
		</form>
	</div>
</div>
<script type="text/javascript">
	$(function() {
		$('.btn-primary').on('click', function() {
			var that = this;
			if ($('.form-horizontal').validation(function(status, dom, errorMsg, defaultValue) {
				status ? function() {
					$(dom).parent().parent().removeClass('has-error').addClass('has-success');
				}.call() : function() {
					validationFail(errorMsg, dom);
					$(dom).parent().parent().removeClass('has-success').addClass('has-error');
				}.call();
			})) {
				$.post(getRootPath() + '/team/create', $('.form-horizontal').serialize(), function(result) {
					if (result.operationState == 'SUCCESS') {
						validationFail('添加团队 ' + result.data.team.name + ' 成功', $(that));
						setTimeout(function() {
							location.href = '${base}'
						}, 2000);
					} else {
						validationFail(result.data.reason, $(that));
					}
				}, 'json')
			}
		})
	})
</script>
<!--# } #-->